<?php
require_once("lib/curl.php");
require_once("config.php");

Doctrine::loadModels('models');

$desti = "data/guildlist.xml";

// Download from 'example.com' to 'example.txt'
cURLdownload("http://www.wowarmory.com/guild-info.xml?r=Shadowmoon&n=Fallen+Redemption", $desti);
#echo phpinfo();

$xmlFileData = file_get_contents($desti);
$xmlData = new SimpleXMLElement($xmlFileData);
//And here's the output.

//print_r($xmlData);

$raiderTable = Doctrine::getTable('Raider');

foreach ($xmlData->guildInfo->guild->members->character as $char){
	print("Name: " .  $char['name'] . " Class: " . $char['class'] . "\r\n" );
	$raider = $raiderTable->find($char['name']);
	if($raider === null || !isset($raider->name)){
	        print("not found\r\n");
		$raider = new Raider();
		$raider->name = $char['name'];
		$raider->class = $char['class'];
		$raider->save();
	} else {
		print("FOUND... ");
		print($raider .  "\r\n");
	}
}

?>
